// import foo from './foo'
// import bar from './bar'
import './global.css'

const render = () => {
  const hash = window.location.hash || '#foo'
  const mainElement = document.querySelector('.main')
  mainElement.innerHTML = ''

  if (hash === '#foo') {
    // mainElement.appendChild(foo())
    import(/* webpackChunkName: 'foo' */'./foo').then(({default: foo}) => {
      mainElement.appendChild(foo())
    })
  } else if (hash === '#bar') {
    import(/* webpackChunkName: 'bar' */'./bar').then(({default: bar}) => {
      mainElement.appendChild(bar())
    })
  }
}

console.log('render')
render()
window.addEventListener('hashchange', render)
